package com.share.common.utils;


import com.alibaba.druid.pool.DruidDataSource;

import javax.sql.DataSource;

/**
 * created by caifan 2018/03/02
 */
public class DataSourceUtils {
    private static final String URL_PREFIX = "jdbc:mysql://localhost:3306/";

    private static final String USER_NAME = "root";

    private static final String PASSWORD = "123456";

   public static DataSource createDataSource(final String dataSourceName) {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setKeepAlive(true);
        dataSource.setDriverClassName(com.mysql.jdbc.Driver.class.getName());
        dataSource.setUrl(URL_PREFIX + dataSourceName);
        dataSource.setUsername(USER_NAME);
        dataSource.setPassword(PASSWORD);
        return dataSource;
    }
}
